# 基础镜像
FROM openjdk:8

# 设置工作目录
WORKDIR /usr/local/charging

# 复制应用程序JAR包
#COPY ./target/charging-admin.jar /usr/charging/charging-admin.jar

# 复制日志备份脚本
#COPY backup_logs.sh /usr/charging/backup_logs.sh
# RUN chmod +x ./charging-admin.jar && ls -l ./charging-admin.jar
# RUN chmod +x ./backup_logs.sh && ls -l ./backup_logs.sh

# 设置环境变量
ENV JAVA_OPTS="-Xms512m -Xmx1024m"
ENV TZ=Asia/Shanghai

# 启动命令
CMD ["sh", "-c", "java $JAVA_OPTS -jar charging-admin.jar & \
         trap 'bash backup_logs.sh; kill -TERM $!' TERM INT; \
         wait $!"]